package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallPermission;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface HaogoumallPermissionMapper {
    @Delete({
        "delete from haogoumall_permission",
        "where permission_id = #{permissionId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer permissionId);

    @Insert({
        "insert into haogoumall_permission (permission_id, role_id, ",
        "permission, permission_add_time, ",
        "permission_update_time, permission_deleted)",
        "values (#{permissionId,jdbcType=INTEGER}, #{roleId,jdbcType=INTEGER}, ",
        "#{permission,jdbcType=VARCHAR}, #{permissionAddTime,jdbcType=TIMESTAMP}, ",
        "#{permissionUpdateTime,jdbcType=TIMESTAMP}, #{permissionDeleted,jdbcType=BIT})"
    })
    int insert(HaogoumallPermission record);

    @InsertProvider(type=HaogoumallPermissionSqlProvider.class, method="insertSelective")
    int insertSelective(HaogoumallPermission record);

    @Select({
        "select",
        "permission_id, role_id, permission, permission_add_time, permission_update_time, ",
        "permission_deleted",
        "from haogoumall_permission",
        "where permission_id = #{permissionId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="permission_id", property="permissionId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="role_id", property="roleId", jdbcType=JdbcType.INTEGER),
        @Result(column="permission", property="permission", jdbcType=JdbcType.VARCHAR),
        @Result(column="permission_add_time", property="permissionAddTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="permission_update_time", property="permissionUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="permission_deleted", property="permissionDeleted", jdbcType=JdbcType.BIT)
    })
    HaogoumallPermission selectByPrimaryKey(Integer permissionId);

    @UpdateProvider(type=HaogoumallPermissionSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(HaogoumallPermission record);

    @Update({
        "update haogoumall_permission",
        "set role_id = #{roleId,jdbcType=INTEGER},",
          "permission = #{permission,jdbcType=VARCHAR},",
          "permission_add_time = #{permissionAddTime,jdbcType=TIMESTAMP},",
          "permission_update_time = #{permissionUpdateTime,jdbcType=TIMESTAMP},",
          "permission_deleted = #{permissionDeleted,jdbcType=BIT}",
        "where permission_id = #{permissionId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(HaogoumallPermission record);
}